cmake_minimum_required(VERSION 3.8)
project(binocular_driver)

## Use C++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(cv_bridge_DIR "/opt/ros/humble/share/cv_bridge/cmake")


## By adding -Wall and -Werror, the compiler does not ignore warnings anymore,
## enforcing cleaner code.
add_definitions(-Wall -Werror)

## Export compile commands for clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(ament_cmake_auto REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(rclcpp REQUIRED)
find_package(OpenCV REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(image_transport REQUIRED)
find_package(usb_cam REQUIRED)
find_package(camera_info_manager REQUIRED)
find_package(image_geometry REQUIRED)
find_package(tf2 REQUIRED)

ament_auto_find_build_dependencies()

ament_auto_add_library(${PROJECT_NAME} SHARED
  src/binocular_driver_node.cpp
)

ament_auto_add_executable(tf_broadcaster_node
  src/tf_broadcaster.cpp
)

target_include_directories(${PROJECT_NAME} PUBLIC ${OpenCV_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})

rclcpp_components_register_node(${PROJECT_NAME}
  PLUGIN binocular_driver::binocular_driver_node
  EXECUTABLE ${PROJECT_NAME}_node
)

find_package (ament_cmake_auto REQUIRED) 
ament_auto_find_build_dependencies ()

# ament_auto_add_library ( my_lib SHARED 
#     src/example.cpp 
#     include/example.hpp)

ament_auto_package (  
  INSTALL_TO_SHARE
  launch
  config)